package someTestExcemple.thread.communication;

import java.util.concurrent.BlockingQueue;

public class Producer extends Thread{
    private BlockingQueue<String> blockingQueue;

    public Producer(BlockingQueue<String> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; i < 5; i++) {
                System.out.println("Put value:" + i);
                blockingQueue.put(String.valueOf(i));
                Thread.sleep(1000);
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
